package com.ruoyi.zxjd.demeanor.service.impl;

import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.zxjd.common.mapper.CommonMapper;
import com.ruoyi.zxjd.demeanor.domain.DemeanorArrange;
import com.ruoyi.zxjd.demeanor.mapper.DemeanorArrangeMapper;
import com.ruoyi.zxjd.demeanor.service.IDemeanorArrangeService;
import com.ruoyi.zxjd.work.service.IWorkHandleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 纪检风采Service业务层处理
 *
 * @author lcc
 * @date 2021-04-08
 */
@Service
public class DemeanorArrangeServiceImpl implements IDemeanorArrangeService {
    @Autowired
    private DemeanorArrangeMapper demeanorArrangeMapper;

    @Autowired
    private CommonMapper commonMapper;


    @Autowired
    private IWorkHandleService workHandleService;

    /**
     * 查询纪检风采
     *
     * @param arrangeId 纪检风采ID
     * @return 纪检风采
     */
    @Override
    public DemeanorArrange selectDemeanorArrangeById(Long arrangeId) {
        return demeanorArrangeMapper.selectDemeanorArrangeById(arrangeId);
    }

    /**
     * 查询纪检风采列表
     *
     * @param demeanorArrange 纪检风采
     * @return 纪检风采
     */
    @Override
    public List<DemeanorArrange> selectDemeanorArrangeList(DemeanorArrange demeanorArrange) {
        return demeanorArrangeMapper.selectDemeanorArrangeList(demeanorArrange);
    }

    /**
     * 新增纪检风采
     *
     * @param demeanorArrange 纪检风采
     * @return 结果
     */
    @Override
    public int insertDemeanorArrange(DemeanorArrange demeanorArrange) {
        demeanorArrange.setCreateBy(ShiroUtils.getLoginName());
        demeanorArrange.setCreateTime(DateUtils.getNowDate());
        return demeanorArrangeMapper.insertDemeanorArrange(demeanorArrange);
    }

    /**
     * 修改纪检风采
     *
     * @param demeanorArrange 纪检风采
     * @return 结果
     */
    @Override
    public int updateDemeanorArrange(DemeanorArrange demeanorArrange) {
        demeanorArrange.setUpdateBy(ShiroUtils.getLoginName());
        demeanorArrange.setUpdateTime(DateUtils.getNowDate());
        return demeanorArrangeMapper.updateDemeanorArrange(demeanorArrange);
    }

    /**
     * 删除纪检风采对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteDemeanorArrangeByIds(String ids) {
        return demeanorArrangeMapper.deleteDemeanorArrangeByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除纪检风采信息
     *
     * @param arrangeId 纪检风采ID
     * @return 结果
     */
    @Override
    public int deleteDemeanorArrangeById(Long arrangeId) {
        return demeanorArrangeMapper.deleteDemeanorArrangeById(arrangeId);
    }


    /**
     * 通过工作安排ID修改工作安排状态
     *
     * @param arrangeId 工作安排ID
     * @param status    工作状态（1草稿 2已发布）
     * @return
     */
    @Override
    public int updateStatusByArrangeId(Long arrangeId, String status) {
        demeanorArrangeMapper.updateStatusByArrangeId(arrangeId, Integer.valueOf(status));
        return 1;
    }


    @Override
    public int totalCount() {
        return demeanorArrangeMapper.totalCount();
    }

    @Override
    public List<DemeanorArrange> selectDemeanorArrangeList(Map<String,Object> map) {
        return demeanorArrangeMapper.selectDemeanorArrangeListPage(map);
    }

    @Override
    public List<DemeanorArrange> selectDemeanorArrangeWithPicPathListAndPage(DemeanorArrange demeanorArrange,Integer offset, Integer limit) {

        return  demeanorArrangeMapper.selectDemeanorArrangeWithPicPathList(demeanorArrange, offset, limit);
    }
}
